jQuery(function($){
  $(document).on("click", "a.js-staff-to-reset-pwd", function(){
    var id = $(this).data("id");
    var storeId = $(this).data('store-id');
    console.log(storeId);
    var input = "登录名: <input type='text' name='login_name' class='ttd js-reset-authenticate-dialog-login-name' required='true' /><br>"+
                "　密码: <input type='password' name='password' class='ttd js-reset-authenticate-dialog-password' required='true'/>"
    commonEvents.popupView("公司超级管理员验证：", input, "确 定")
    $("button#modal_okBtn").on("click", function(){
      var loginName = $("input.js-reset-authenticate-dialog-login-name").val();
      var pwd = $("input.js-reset-authenticate-dialog-password").val();
      console.log(loginName);
      if (loginName == null || loginName == ""){
        showErrorView("请填写用户名");
        return false
      }else if (pwd == null || pwd == ""){
        showErrorView("请填写密码");
        return false
      }else {
        $.ajax({
          url: "/api/store_staffs/authenticate",
          type: 'get',
          data: {store_id: storeId, login_name: loginName, password: pwd},
          success: function(data){
            if (data.status == true){
              location.href = "/ems/store_staffs/"+ id +"/pwd?store_id="+ data.store_id
            }else {
              showErrorView(data.msg);
              return false
            }
          },
          error: function(data){

          }
        })
      }

    })
  }) // end to reset pwd


})
